/// Mat 基本操作2
/// Mat inv, t, eigen, sobel 等
#include "opencv2/core.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgproc.hpp"
#include <iostream>

using namespace std;
using namespace cv;


int main(int argc, char const *argv[])
{
    // A transpose, inverse
    cv::Mat A =  (cv::Mat_<float>(3, 3) << 1, 2, 3, 2, 2, 1, 3, 4, 3);
    cv::Mat invA = A.inv();

    {
        vector<double> values(0);
        cv::KeyPoint kp;
        vector<cv::KeyPoint> otherKeyPoints;
        cout << otherKeyPoints.size();
        //cout << kp.size << endl;
        //values.push_back(0);
    }

    cout << "A:\n" << A << endl;
    cout << "A.t()\n" << A.t() << endl;
    cout << "A.inv()\n" << A.inv() << endl;
    cout << "A.diag()\n" << A.diag() << endl;
    cout << "det(A)\n" << cv::determinant(A) << endl;

    cv::Mat eigenValues, eigenVector;
    cv::eigen(A, eigenValues, eigenVector);
    cout << "eigen values: " << eigenValues << endl;
    cout << "eigen vector: " << eigenVector << endl;

    // 获取3x3 Sobel 算子
    cout << "kernels:\n";
    {
        Mat kx, ky;
        getDerivKernels(kx, ky, 1, 0, 3, false, CV_32F);
        cout << "kx:\n" << kx << endl;
        cout << "ky:\n" << ky << endl;
        Mat ksobelX = ky * kx.t();
        cout << "ksobelX: \n" << ksobelX << endl;
    }
    {
        Mat kx, ky;
        getDerivKernels(kx, ky, 0, 1, 3, false, CV_32F);
        cout << "kx:\n" << kx << endl;
        cout << "ky:\n" << ky << endl;
        Mat ksobelY = ky * kx.t();
        cout << "ksobelY: \n" << ksobelY << endl;
    }

    cv::Mat sobelx, sobely;
    cv::Sobel(A, sobelx, CV_32F, 1, 0);
    cout << "sobelx:\n" << sobelx << endl;
    cv::Sobel(A, sobely, CV_32F, 0, 1);
    cout << "sobely:\n" << sobely << endl;

    return 0; 
}
